from nonebot import on_startswith
from nonebot.adapters import Event
from nonebot.adapters.onebot.v11 import MessageSegment
from .compile import Compile


command = on_startswith(("/latex -f", "/latex --full"))

@command.handle()
async def handler(event: Event):
    message = event.get_message().extract_plain_text().replace("/latex -f", "", 1).replace("/latex --full", "", 1)
    result = Compile(message).run()
    for item in result:
        await command.send(MessageSegment.image(item))
    await command.finish()
   